package gatech.cs2340.adventuretime.persistent.users;

import gatech.cs2340.adventuretime.persistent.records.Appointment;
import gatech.cs2340.adventuretime.persistent.records.Invoice;
import gatech.cs2340.adventuretime.persistent.records.Record;
import gatech.cs2340.adventuretime.persistent.records.Diagnosis;

import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;

public class Patient extends User {
	

	/**
	 * holds every date the patient has been weighed and its weight
	 */
	private HashMap<Date,Integer> weightHistory;
	/**
	 * the last date the patient was weighed, this is used privately to get the patient's weight
	 */
	private Date lastWeightDate;
	
	
	/**
	 * Only allowing users to be created strictly with a name and password, for db stability
	 * We don't provide a default constructor for this purpose.
	 * @param username for all users
	 * @param password for all users
	 */
	public Patient(String username, String password) {
		super(username, password);
		weightHistory = new HashMap<Date, Integer>();
		
		// TODO initialize patient's instance vars
	}
	/**
	 * generate a cool graph of the patient's weight with this
	 * @return hashmap of the weight/dates.
	 */
	public HashMap<Date, Integer> getWeightHistory() {
		return weightHistory;
	}
	/**
	 * this will check a weight to make sure you didn't add extra zeros.
	 * @param date
	 * @param weight
	 * @return
	 */
	public boolean addWeight(Date date, int weight){
		//So, nobody over 600lbs please. should this be higher? will this offend someone somewhere?
		//Suggestion: throw(FATAL WEIGHT EXCEPTION)
		if(weight > 0 && weight < 700)
		{
			this.lastWeightDate = date;
			weightHistory.put(date, weight);
			return true;
		}
		return false;
	}
	/**
	 * this returns, as English has us expect, the patient's weight. (weightHistory.last)
	 * @return the current weight of the patient
	 */
	public int getWeight() {
		return this.weightHistory.get(lastWeightDate);
	}
	
	


	
	
	

}
